<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Running Ibator With Java</title>
  <link type="text/css" rel="stylesheet" href="../ibator.css"/>
</head>
<body>

<div class="menuNav">
  <p>
    <a href="../index.html" target="_top">Show Menu</a>
    <a href="runningWithJava.html" target="_top">Hide Menu</a>
  </p>
</div>

<h1>Running Ibator With Java</h1>
<h2>Running Ibator from Java with an XML Configuration File</h2>
<p>The following code sample shows how to call Ibator from Java.  It does not
   show exception handling, but that should be obvious from the compiler
   errors :)</p>
<pre>
   List&lt;String&gt; warnings = new ArrayList&lt;String&gt;();
   boolean overwrite = true;
   File configFile = new File("ibatorConfig.xml");
   IbatorConfigurationParser cp = new IbatorConfigurationParser(warnings);
   IbatorConfiguration config = cp.parseIbatorConfiguration(configFile);
   DefaultShellCallback callback = new DefaultShellCallback(overwrite);
   Ibator ibator = new Ibator(config, callback, warnings);
   ibator.generate(null);
</pre>

<p>Notes:</p>
<ul>
   <li>Configuration file properties may be passed to the parser as a parameter on
       the IbatorConfigurationParser constructor.  If not passed explicitly, the JVM
       system properties will be searched for the value of configuration file
       properties.  For example, the property
       <code>generated.source.dir</code> can be
       accessed in the Ibator configuration file with the escape sequence
       <code>${generated.source.dir}</code>
   </li>
   <li>If a property is specified in the configuration file and is not resolved,
       then the escaped property string will be passed "as is" into the generated code.
   </li>
</ul>

<h2>Running Ibator from Java with a Java Based Configuration</h2>
<p>The following code sample shows how to call Ibator from Java only.  It does
   not show exception handling, but that should be obvious from the compiler
   errors :)</p>
<pre>
   List&lt;String&gt; warnings = new ArrayList&lt;String&gt;();
   boolean overwrite = true;
   IbatorConfiguration config = new IbatorConfiguration();

   //   ... fill out the config object as appropriate...

   DefaultShellCallback callback = new DefaultShellCallback(overwrite);
   Ibator ibator = new Ibator(config, callback, warnings);
   ibator.generate(null);
</pre>

</body>
</html>